package com.wutong.teacher_server.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Create By Administrator on 2021/6/30.
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //添加映射路径
        registry.addMapping("/**")
                //放行哪些原始请求头部信息
                .allowedHeaders("*")
                //放行哪些请求方式
                .allowedMethods("*")
                //是否发送Cookie
                .allowCredentials(true)
                //设置放行哪些原始域
                .allowedOrigins("*")
                .maxAge(2000);
    }
}
